package com.example.myblog_ssm.service;

import com.example.myblog_ssm.entity.UserInfo;
import com.example.myblog_ssm.mapper.UserInfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22479
 * Date: 2023-03-20
 * Time: 22:41
 */
@Service
public class UserInfoService {

    @Resource
    private UserInfoMapper userInfoMapper;

    /**
     * 注册新用户
     *
     * @param userInfo
     * @return
     */
    public int insert(UserInfo userInfo) {
        return userInfoMapper.insert(userInfo);
    }

    /**
     * 登录验证 / 忘记密码按照用户名查找用户信息
     *
     * @param username
     * @return
     */
    public UserInfo getUserByName(String username) {
        return userInfoMapper.getUserByName(username);
    }

    /**
     * 通过ID查找用户信息
     *
     * @param id
     * @return
     */
    public UserInfo getUserById(Integer id) {
        return userInfoMapper.getUserById(id);
    }

    /**
     * 修改/忘记密码
     *
     * @param userInfo
     * @return
     */
    public int findpsw(UserInfo userInfo) {
        return userInfoMapper.findpsw(userInfo);
    }

    /**
     * 修改昵称
     *
     * @param userInfo
     * @return
     */
    public int updatenickname(UserInfo userInfo) {
        return userInfoMapper.updatenickname(userInfo);
    }
}
